<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>sqs.parsers</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="sqs-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="sqs-module.html">Package&nbsp;sqs</a> ::
        Module&nbsp;parsers
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="sqs.parsers-pysrc.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="sqs.parsers-module.html">Module sqs.parsers</a></h1>
<pre class="py-src">
<tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-0" class="py-name" targets="Package sqs=sqs-module.html"><a title="sqs" class="py-name" href="#" onclick="return doclink('link-0', 'sqs', 'link-0');">sqs</a></tt></tt><tt class="py-op">.</tt><tt id="link-1" class="py-name" targets="Module sqs.errors=sqs.errors-module.html"><a title="sqs.errors" class="py-name" href="#" onclick="return doclink('link-1', 'errors', 'link-1');">errors</a></tt></tt> <tt class="py-keyword">import</tt> <tt id="link-2" class="py-name" targets="Class sqs.errors.SQSError=sqs.errors.SQSError-class.html"><a title="sqs.errors.SQSError" class="py-name" href="#" onclick="return doclink('link-2', 'SQSError', 'link-2');">SQSError</a></tt></tt> </tt>
<tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt id="link-3" class="py-name"><a title="sqs" class="py-name" href="#" onclick="return doclink('link-3', 'sqs', 'link-0');">sqs</a></tt></tt> </tt>
<tt class="py-lineno">  3</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">  5</tt>  <tt class="py-line">    <tt class="py-keyword">import</tt> <tt class="py-name">cElementTree</tt> <tt class="py-name">as</tt> <tt class="py-name">et</tt> </tt>
<tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-keyword">except</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno">  7</tt>  <tt class="py-line">    <tt class="py-keyword">from</tt> <tt class="py-name">elementtree</tt> <tt class="py-keyword">import</tt> <tt class="py-name">ElementTree</tt> <tt class="py-name">as</tt> <tt class="py-name">et</tt> </tt>
<tt class="py-lineno">  8</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno">  9</tt>  <tt class="py-line"><tt id="link-4" class="py-name" targets="Variable sqs.parsers.xmlns=sqs.parsers-module.html#xmlns"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-4', 'xmlns', 'link-4');">xmlns</a></tt></tt> <tt class="py-op">=</tt> <tt class="py-string">"http://queue.amazonaws.com/doc/"</tt> <tt class="py-op">+</tt> <tt id="link-5" class="py-name"><a title="sqs" class="py-name" href="#" onclick="return doclink('link-5', 'sqs', 'link-0');">sqs</a></tt></tt><tt class="py-op">.</tt><tt id="link-6" class="py-name" targets="Variable sqs.VERSION=sqs-module.html#VERSION"><a title="sqs.VERSION" class="py-name" href="#" onclick="return doclink('link-6', 'VERSION', 'link-6');">VERSION</a></tt></tt> <tt class="py-op">+</tt> <tt class="py-string">'/'</tt> </tt>
<tt class="py-lineno"> 10</tt>  <tt class="py-line"> </tt>
<a name="parseError"></a><div id="parseError-def"><tt class="py-lineno"> 11</tt> <a class="py-toggle" href="#" id="parseError-toggle" onclick="return toggle('parseError');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="sqs.parsers-module.html#parseError">parseError</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseError-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseError-expanded"><tt class="py-lineno"> 12</tt>  <tt class="py-line">    <tt class="py-docstring">'''</tt> </tt>
<tt class="py-lineno"> 13</tt>  <tt class="py-line"><tt class="py-docstring">    Parse the response XML if error occured, and creates an SQSError exception.</tt> </tt>
<tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-docstring">    @param xml: The XML error response</tt> </tt>
<tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-docstring">    @type  xml: string</tt> </tt>
<tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-docstring">    @return:    Returns the SQSError exception</tt> </tt>
<tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype:     SQSError</tt> </tt>
<tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<tt class="py-lineno"> 20</tt>  <tt class="py-line">    <tt class="py-keyword">print</tt> <tt class="py-string">"Dosao sam u parseError:\n"</tt><tt class="py-op">,</tt> <tt class="py-name">xml</tt> </tt>
<tt class="py-lineno"> 21</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 22</tt>  <tt class="py-line">    <tt class="py-name">code</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'Errors/Error/Code'</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 23</tt>  <tt class="py-line">    <tt id="link-7" class="py-name" targets="Variable sqs.objects.SQSMessage.body=sqs.objects.SQSMessage-class.html#body"><a title="sqs.objects.SQSMessage.body" class="py-name" href="#" onclick="return doclink('link-7', 'body', 'link-7');">body</a></tt></tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'Errors/Error/Message'</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 24</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">code</tt> <tt class="py-op">==</tt> <tt class="py-string">'MissingParameter'</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 25</tt>  <tt class="py-line">        <tt class="py-name">missing_parameter</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'MissingParameterName'</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 26</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">missing_parameter</tt><tt class="py-op">:</tt> <tt class="py-name">reason</tt> <tt class="py-op">=</tt> <tt class="py-name">missing_parameter</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 27</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> <tt class="py-name">reason</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt> </tt>
<tt class="py-lineno"> 28</tt>  <tt class="py-line">    <tt class="py-keyword">elif</tt> <tt class="py-name">code</tt> <tt class="py-op">==</tt> <tt class="py-string">'AccessFailure'</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 29</tt>  <tt class="py-line">        <tt class="py-name">service_name</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'ServiceName'</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 30</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">service_name</tt><tt class="py-op">:</tt> <tt class="py-name">reason</tt> <tt class="py-op">=</tt> <tt class="py-name">service_name</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 31</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> <tt class="py-name">reason</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt> </tt>
<tt class="py-lineno"> 32</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 33</tt>  <tt class="py-line">        <tt class="py-name">reason</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt> </tt>
<tt class="py-lineno"> 34</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-8" class="py-name"><a title="sqs.errors.SQSError" class="py-name" href="#" onclick="return doclink('link-8', 'SQSError', 'link-2');">SQSError</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">code</tt><tt class="py-op">,</tt> <tt class="py-name">reason</tt><tt class="py-op">,</tt> <tt id="link-9" class="py-name"><a title="sqs.objects.SQSMessage.body" class="py-name" href="#" onclick="return doclink('link-9', 'body', 'link-7');">body</a></tt></tt><tt class="py-op">)</tt> </tt>
</div><tt class="py-lineno"> 35</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 36</tt>  <tt class="py-line"> </tt>
<a name="parseQueueList"></a><div id="parseQueueList-def"><tt class="py-lineno"> 37</tt> <a class="py-toggle" href="#" id="parseQueueList-toggle" onclick="return toggle('parseQueueList');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="sqs.parsers-module.html#parseQueueList">parseQueueList</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">,</tt> <tt class="py-param">connection</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseQueueList-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseQueueList-expanded"><tt class="py-lineno"> 38</tt>  <tt class="py-line">    <tt class="py-docstring">'''Parse the response XML for listing queues</tt> </tt>
<tt class="py-lineno"> 39</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt class="py-docstring">    @param xml:        The XML response</tt> </tt>
<tt class="py-lineno"> 41</tt>  <tt class="py-line"><tt class="py-docstring">    @type  xml:        string</tt> </tt>
<tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-docstring">    @param connection: SQSConnection to the server</tt> </tt>
<tt class="py-lineno"> 43</tt>  <tt class="py-line"><tt class="py-docstring">    @type  connection: SQSConnection</tt> </tt>
<tt class="py-lineno"> 44</tt>  <tt class="py-line"><tt class="py-docstring">    @return:           List of queues</tt> </tt>
<tt class="py-lineno"> 45</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype:            list</tt> </tt>
<tt class="py-lineno"> 46</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<tt class="py-lineno"> 47</tt>  <tt class="py-line">    <tt class="py-name">queues</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<tt class="py-lineno"> 48</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 49</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">node</tt> <tt class="py-keyword">in</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">findall</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}QueueUrl'</tt> <tt class="py-op">%</tt> <tt id="link-10" class="py-name"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-10', 'xmlns', 'link-4');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 50</tt>  <tt class="py-line">        <tt class="py-name">queues</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt id="link-11" class="py-name"><a title="sqs" class="py-name" href="#" onclick="return doclink('link-11', 'sqs', 'link-0');">sqs</a></tt></tt><tt class="py-op">.</tt><tt id="link-12" class="py-name" targets="Class sqs.objects.SQSQueue=sqs.objects.SQSQueue-class.html"><a title="sqs.objects.SQSQueue" class="py-name" href="#" onclick="return doclink('link-12', 'SQSQueue', 'link-12');">SQSQueue</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">node</tt><tt class="py-op">.</tt><tt class="py-name">text</tt><tt class="py-op">,</tt> <tt id="link-13" class="py-name" targets="Module sqs.connection=sqs.connection-module.html"><a title="sqs.connection" class="py-name" href="#" onclick="return doclink('link-13', 'connection', 'link-13');">connection</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 51</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">queues</tt> </tt>
</div><tt class="py-lineno"> 52</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 53</tt>  <tt class="py-line"> </tt>
<a name="parseQueueCreation"></a><div id="parseQueueCreation-def"><tt class="py-lineno"> 54</tt> <a class="py-toggle" href="#" id="parseQueueCreation-toggle" onclick="return toggle('parseQueueCreation');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="sqs.parsers-module.html#parseQueueCreation">parseQueueCreation</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">,</tt> <tt class="py-param">connection</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseQueueCreation-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseQueueCreation-expanded"><tt class="py-lineno"> 55</tt>  <tt class="py-line">    <tt class="py-docstring">'''Parse the response XML returned on queue creation</tt> </tt>
<tt class="py-lineno"> 56</tt>  <tt class="py-line"><tt class="py-docstring">    </tt> </tt>
<tt class="py-lineno"> 57</tt>  <tt class="py-line"><tt class="py-docstring">    @param xml:        The XML response</tt> </tt>
<tt class="py-lineno"> 58</tt>  <tt class="py-line"><tt class="py-docstring">    @type  xml:        string</tt> </tt>
<tt class="py-lineno"> 59</tt>  <tt class="py-line"><tt class="py-docstring">    @param connection: SQSConnection to the server</tt> </tt>
<tt class="py-lineno"> 60</tt>  <tt class="py-line"><tt class="py-docstring">    @type  connection: SQSConnection</tt> </tt>
<tt class="py-lineno"> 61</tt>  <tt class="py-line"><tt class="py-docstring">    @return:           Newly created queue</tt> </tt>
<tt class="py-lineno"> 62</tt>  <tt class="py-line"><tt class="py-docstring">    @rtype:            SQSQueue</tt> </tt>
<tt class="py-lineno"> 63</tt>  <tt class="py-line"><tt class="py-docstring">    '''</tt> </tt>
<tt class="py-lineno"> 64</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 65</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-14" class="py-name"><a title="sqs" class="py-name" href="#" onclick="return doclink('link-14', 'sqs', 'link-0');">sqs</a></tt></tt><tt class="py-op">.</tt><tt id="link-15" class="py-name"><a title="sqs.objects.SQSQueue" class="py-name" href="#" onclick="return doclink('link-15', 'SQSQueue', 'link-12');">SQSQueue</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}QueueUrl'</tt> <tt class="py-op">%</tt> <tt id="link-16" class="py-name"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-16', 'xmlns', 'link-4');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt><tt class="py-op">,</tt> <tt id="link-17" class="py-name"><a title="sqs.connection" class="py-name" href="#" onclick="return doclink('link-17', 'connection', 'link-13');">connection</a></tt></tt><tt class="py-op">)</tt> </tt>
</div><tt class="py-lineno"> 66</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 67</tt>  <tt class="py-line"> </tt>
<a name="parseTimeout"></a><div id="parseTimeout-def"><tt class="py-lineno"> 68</tt> <a class="py-toggle" href="#" id="parseTimeout-toggle" onclick="return toggle('parseTimeout');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="sqs.parsers-module.html#parseTimeout">parseTimeout</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseTimeout-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseTimeout-expanded"><tt class="py-lineno"> 69</tt>  <tt class="py-line">    <tt class="py-keyword">pass</tt> </tt>
</div><tt class="py-lineno"> 70</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 71</tt>  <tt class="py-line"> </tt>
<a name="parseMessageCreate"></a><div id="parseMessageCreate-def"><tt class="py-lineno"> 72</tt> <a class="py-toggle" href="#" id="parseMessageCreate-toggle" onclick="return toggle('parseMessageCreate');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="sqs.parsers-module.html#parseMessageCreate">parseMessageCreate</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseMessageCreate-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseMessageCreate-expanded"><tt class="py-lineno"> 73</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 74</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}MessageId'</tt> <tt class="py-op">%</tt> <tt id="link-18" class="py-name"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-18', 'xmlns', 'link-4');">xmlns</a></tt></tt><tt class="py-op">)</tt> </tt>
</div><tt class="py-lineno"> 75</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 76</tt>  <tt class="py-line"> </tt>
<a name="parseMessageRead"></a><div id="parseMessageRead-def"><tt class="py-lineno"> 77</tt> <a class="py-toggle" href="#" id="parseMessageRead-toggle" onclick="return toggle('parseMessageRead');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="sqs.parsers-module.html#parseMessageRead">parseMessageRead</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseMessageRead-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseMessageRead-expanded"><tt class="py-lineno"> 78</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 79</tt>  <tt class="py-line">    <tt class="py-name">message</tt> <tt class="py-op">=</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Message'</tt> <tt class="py-op">%</tt> <tt id="link-19" class="py-name"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-19', 'xmlns', 'link-4');">xmlns</a></tt></tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 80</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">message</tt> <tt class="py-op">!=</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 81</tt>  <tt class="py-line">        <tt class="py-name">id</tt> <tt class="py-op">=</tt> <tt class="py-name">message</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}MessageId'</tt> <tt class="py-op">%</tt> <tt id="link-20" class="py-name"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-20', 'xmlns', 'link-4');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 82</tt>  <tt class="py-line">        <tt id="link-21" class="py-name"><a title="sqs.objects.SQSMessage.body" class="py-name" href="#" onclick="return doclink('link-21', 'body', 'link-7');">body</a></tt></tt> <tt class="py-op">=</tt> <tt class="py-name">message</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}MessageBody'</tt> <tt class="py-op">%</tt> <tt id="link-22" class="py-name"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-22', 'xmlns', 'link-4');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 83</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt id="link-23" class="py-name"><a title="sqs" class="py-name" href="#" onclick="return doclink('link-23', 'sqs', 'link-0');">sqs</a></tt></tt><tt class="py-op">.</tt><tt id="link-24" class="py-name" targets="Class sqs.objects.SQSMessage=sqs.objects.SQSMessage-class.html"><a title="sqs.objects.SQSMessage" class="py-name" href="#" onclick="return doclink('link-24', 'SQSMessage', 'link-24');">SQSMessage</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">id</tt><tt class="py-op">=</tt><tt class="py-name">id</tt><tt class="py-op">,</tt> <tt id="link-25" class="py-name"><a title="sqs.objects.SQSMessage.body" class="py-name" href="#" onclick="return doclink('link-25', 'body', 'link-7');">body</a></tt></tt><tt class="py-op">=</tt><tt id="link-26" class="py-name"><a title="sqs.objects.SQSMessage.body" class="py-name" href="#" onclick="return doclink('link-26', 'body', 'link-7');">body</a></tt></tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 84</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">None</tt> </tt>
</div><tt class="py-lineno"> 85</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 86</tt>  <tt class="py-line"> </tt>
<a name="parseMessagesRead"></a><div id="parseMessagesRead-def"><tt class="py-lineno"> 87</tt> <a class="py-toggle" href="#" id="parseMessagesRead-toggle" onclick="return toggle('parseMessagesRead');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="sqs.parsers-module.html#parseMessagesRead">parseMessagesRead</a><tt class="py-op">(</tt><tt class="py-param">xml</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="parseMessagesRead-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parseMessagesRead-expanded"><tt class="py-lineno"> 88</tt>  <tt class="py-line">    <tt class="py-name">messages</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<tt class="py-lineno"> 89</tt>  <tt class="py-line">    <tt class="py-name">root</tt> <tt class="py-op">=</tt> <tt class="py-name">et</tt><tt class="py-op">.</tt><tt class="py-name">fromstring</tt><tt class="py-op">(</tt><tt class="py-name">xml</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 90</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">message</tt> <tt class="py-keyword">in</tt> <tt class="py-name">root</tt><tt class="py-op">.</tt><tt class="py-name">findall</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}Message'</tt> <tt class="py-op">%</tt> <tt id="link-27" class="py-name"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-27', 'xmlns', 'link-4');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<tt class="py-lineno"> 91</tt>  <tt class="py-line">        <tt class="py-name">id</tt> <tt class="py-op">=</tt> <tt class="py-name">message</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}MessageId'</tt> <tt class="py-op">%</tt> <tt id="link-28" class="py-name"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-28', 'xmlns', 'link-4');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 92</tt>  <tt class="py-line">        <tt id="link-29" class="py-name"><a title="sqs.objects.SQSMessage.body" class="py-name" href="#" onclick="return doclink('link-29', 'body', 'link-7');">body</a></tt></tt> <tt class="py-op">=</tt> <tt class="py-name">message</tt><tt class="py-op">.</tt><tt class="py-name">find</tt><tt class="py-op">(</tt><tt class="py-string">'{%s}MessageBody'</tt> <tt class="py-op">%</tt> <tt id="link-30" class="py-name"><a title="sqs.parsers.xmlns" class="py-name" href="#" onclick="return doclink('link-30', 'xmlns', 'link-4');">xmlns</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">text</tt> </tt>
<tt class="py-lineno"> 93</tt>  <tt class="py-line">        <tt class="py-name">messages</tt><tt class="py-op">.</tt><tt class="py-name">append</tt><tt class="py-op">(</tt><tt id="link-31" class="py-name"><a title="sqs" class="py-name" href="#" onclick="return doclink('link-31', 'sqs', 'link-0');">sqs</a></tt></tt><tt class="py-op">.</tt><tt id="link-32" class="py-name"><a title="sqs.objects.SQSMessage" class="py-name" href="#" onclick="return doclink('link-32', 'SQSMessage', 'link-24');">SQSMessage</a></tt></tt><tt class="py-op">(</tt><tt class="py-name">id</tt><tt class="py-op">=</tt><tt class="py-name">id</tt><tt class="py-op">,</tt> <tt id="link-33" class="py-name"><a title="sqs.objects.SQSMessage.body" class="py-name" href="#" onclick="return doclink('link-33', 'body', 'link-7');">body</a></tt></tt><tt class="py-op">=</tt><tt id="link-34" class="py-name"><a title="sqs.objects.SQSMessage.body" class="py-name" href="#" onclick="return doclink('link-34', 'body', 'link-7');">body</a></tt></tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<tt class="py-lineno"> 94</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">messages</tt> </tt>
</div><tt class="py-lineno"> 95</tt>  <tt class="py-line"> </tt>
<tt class="py-lineno"> 96</tt>  <tt class="py-line"><tt class="py-comment">##class GetTimeoutHandler(xml.sax.ContentHandler):</tt> </tt>
<tt class="py-lineno"> 97</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def __init__(self):</tt> </tt>
<tt class="py-lineno"> 98</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.timeout = None</tt> </tt>
<tt class="py-lineno"> 99</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.status = None</tt> </tt>
<tt class="py-lineno">100</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.request_id = None</tt> </tt>
<tt class="py-lineno">101</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.curr_text = ''</tt> </tt>
<tt class="py-lineno">102</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">103</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def endElement(self, name):</tt> </tt>
<tt class="py-lineno">104</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        if name == 'VisibilityTimeout':</tt> </tt>
<tt class="py-lineno">105</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.timeout = int(self.curr_text)</tt> </tt>
<tt class="py-lineno">106</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        elif name == 'StatusCode':</tt> </tt>
<tt class="py-lineno">107</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.status = self.curr_text</tt> </tt>
<tt class="py-lineno">108</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        elif name == 'RequestId':</tt> </tt>
<tt class="py-lineno">109</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.request_id = self.curr_text</tt> </tt>
<tt class="py-lineno">110</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">111</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.curr_text = ''</tt> </tt>
<tt class="py-lineno">112</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">113</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def characters(self, content):</tt> </tt>
<tt class="py-lineno">114</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.curr_text += content</tt> </tt>
<tt class="py-lineno">115</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">116</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">117</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##class GetMessageHandler(xml.sax.ContentHandler):</tt> </tt>
<tt class="py-lineno">118</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def __init__(self, queue, messageClass):</tt> </tt>
<tt class="py-lineno">119</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.queue = queue</tt> </tt>
<tt class="py-lineno">120</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.message = messageClass()</tt> </tt>
<tt class="py-lineno">121</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.message.queue = queue</tt> </tt>
<tt class="py-lineno">122</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.id = None</tt> </tt>
<tt class="py-lineno">123</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.request_id = None</tt> </tt>
<tt class="py-lineno">124</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.curr_text = ''</tt> </tt>
<tt class="py-lineno">125</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">126</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def endElement(self, name):</tt> </tt>
<tt class="py-lineno">127</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        if name == 'MessageId':</tt> </tt>
<tt class="py-lineno">128</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.message.id = self.curr_text</tt> </tt>
<tt class="py-lineno">129</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        elif name == 'MessageBody':</tt> </tt>
<tt class="py-lineno">130</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.message.set_body(self.curr_text)</tt> </tt>
<tt class="py-lineno">131</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        elif name == 'StatusCode':</tt> </tt>
<tt class="py-lineno">132</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.status = self.curr_text</tt> </tt>
<tt class="py-lineno">133</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        elif name == 'RequestId':</tt> </tt>
<tt class="py-lineno">134</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.request_id = self.curr_text</tt> </tt>
<tt class="py-lineno">135</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.curr_text = ''</tt> </tt>
<tt class="py-lineno">136</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">137</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def characters(self, content):</tt> </tt>
<tt class="py-lineno">138</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.curr_text += content</tt> </tt>
<tt class="py-lineno">139</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">140</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">141</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">142</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##class GetMessagesHandler(xml.sax.ContentHandler):</tt> </tt>
<tt class="py-lineno">143</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def __init__(self, queue, messageClass):</tt> </tt>
<tt class="py-lineno">144</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.queue = queue</tt> </tt>
<tt class="py-lineno">145</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.messages = []</tt> </tt>
<tt class="py-lineno">146</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.current_message = None</tt> </tt>
<tt class="py-lineno">147</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.id = None</tt> </tt>
<tt class="py-lineno">148</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.request_id = None</tt> </tt>
<tt class="py-lineno">149</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.curr_text = ''</tt> </tt>
<tt class="py-lineno">150</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self._messageClass = messageClass</tt> </tt>
<tt class="py-lineno">151</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">152</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def startElement(self, name, attrs):</tt> </tt>
<tt class="py-lineno">153</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        if name == 'Message':</tt> </tt>
<tt class="py-lineno">154</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.current_message = self._messageClass()</tt> </tt>
<tt class="py-lineno">155</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.current_message.queue = self.queue</tt> </tt>
<tt class="py-lineno">156</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.messages.append(self.current_message)</tt> </tt>
<tt class="py-lineno">157</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">158</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def endElement(self, name):</tt> </tt>
<tt class="py-lineno">159</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        if name == 'MessageId':</tt> </tt>
<tt class="py-lineno">160</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.current_message.id = self.curr_text</tt> </tt>
<tt class="py-lineno">161</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        elif name == 'MessageBody':</tt> </tt>
<tt class="py-lineno">162</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.current_message.body = self.curr_text</tt> </tt>
<tt class="py-lineno">163</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        elif name == 'StatusCode':</tt> </tt>
<tt class="py-lineno">164</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.status = self.curr_text</tt> </tt>
<tt class="py-lineno">165</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        elif name == 'RequestId':</tt> </tt>
<tt class="py-lineno">166</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##            self.request_id = self.curr_text</tt> </tt>
<tt class="py-lineno">167</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.curr_text = ''</tt> </tt>
<tt class="py-lineno">168</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##</tt> </tt>
<tt class="py-lineno">169</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##    def characters(self, content):</tt> </tt>
<tt class="py-lineno">170</tt>  <tt class="py-line"><tt class="py-comment"></tt><tt class="py-comment">##        self.curr_text += content</tt> </tt>
<tt class="py-lineno">171</tt>  <tt class="py-line"><tt class="py-comment"></tt> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="sqs-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">Generated by Epydoc
        3.0alpha3 on Wed Sep 20 12:10:47 2006</td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
